AddNew Method (Remote Data)

       

Creates a new row for an updatable rdoResultset object.

Syntax

object.AddNew

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

The AddNew method prepares a new row you can edit and subsequently add to the rdoResultset object named by object using the Update method. This method initializes the columns to SQL_IGNORE to ensure columns not specifically referenced are not included in the update operation.

When the AddNew method is executed, the EditMode property is set to rdEditAdd until you execute the Update method.

After you modify the new row, use the Update method to save the changes and add the row to the result set. No changes are made to the database until you use the Update method — unless you are using the Client Batch cursor library — which does not write to the database until the BatchUpdate method is used.

The AddNew method does not return an error if the rdoResultset is not updatable. A trappable error is triggered when the Update method is used against an object that is not updatable. For an object to be updatable, the rdoColumn, rdoResultset, and rdoConnection objects must all be updatable — check the Updatable property of each of these objects before performing an update. There are a variety of reasons why an rdoResultset is not updatable as discussed in the Update method topic.

Caution   If you use the AddNew method on a row and then perform any operation that moves to another row without using Update, your changes are lost without warning. In addition, if you close the object or end the procedure which declares the object or its rdoConnection object, the new row and the changes made to it are discarded without warning.

A newly added row might be visible as a part of the rdoResultset if your data source and type of cursor support it. For example, newly added rows are not included in a static-type rdoResultset.

When newly added rows are included in the rdoResultset, the row that was current before you used AddNew remains current. When the row is added to the cursor keyset, and you want to make the new row current, you can set the Bookmark property to the bookmark identified by the LastModified property setting.

If you need to cancel a pending AddNew operation, use the CancelUpdate method.

When you use the Update method after using the AddNew method, the RowCurrencyChange event is fired.